#include "BasicPrimaryGenerator.hh"



BasicPrimaryGenerator::
	BasicPrimaryGenerator()
{
	position = G4ThreeVector(0,0,0); 
}

BasicPrimaryGenerator::
	~BasicPrimaryGenerator()
{
	// create an iterator "it" that we will use to loop over the 
	// G4VPrimaryGenerator pointers stored in generatorList and
	// delete the objects they point to, freeing their memory. 
	vector<G4VPrimaryGenerator*>::iterator it;

	for(it = generatorList.begin(); it != generatorList.end(); it++)
	{
		// (*it) is a pointer to a G4VPrimaryGenerator*
		// i.e. (*it) is a pointer to a pointer to a G4VPrimaryGenerator object.
		if( *it )
		{
			delete (*it); 
		}
	}
}

void BasicPrimaryGenerator::
	addPrimaryGenerator(G4VPrimaryGenerator* generator)
{
	generatorList.push_back(generator);
}


void BasicPrimaryGenerator::
	GeneratePrimaryVertex(G4Event* evt)
{
	// iteratre over the G4VPrimaryGenerator pointers in 
	// generatorList and call their individual GeneratePrimaryVertex(...)
	// methods.
	vector<G4VPrimaryGenerator*>::iterator it;

	for(it = generatorList.begin(); it != generatorList.end(); it++)
	{
		
		(*it)->GeneratePrimaryVertex(evt);
		
	}
}


void BasicPrimaryGenerator::
	setPosition(G4ThreeVector p)
{
	position = p;
}
